/*
 * Created by JFormDesigner on Sat Jun 22 22:40:30 CST 2024
 */

package scct.chenhui.forms;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;

/**
 * @author chen
 */
public class MainForm extends JFrame {
    java.util.List<JPanel> centerPanelList = new ArrayList<>();
    private PanelUserManager userManager;

    public MainForm() {
        initComponents();
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
//        设置窗口宽度和高度
        setSize(1100,800);
//        窗口居中显示
        setLocationRelativeTo(null);

    }
    private void clearCenterPanel()
    {

    }
    private void btnUser(ActionEvent e) {
        // TODO add your code here

        userManager = new PanelUserManager(this);
        panelMain.removeAll();
        panelMain.add(userManager, BorderLayout.CENTER);
//        getContentPane().add(userManager,BorderLayout.CENTER);
        System.out.println("user");
         revalidate();
         repaint();
//        pack();
//        setSize(1100,800);
//        setLocationRelativeTo(getOwner());

    }

    void addUserPanel(){

    }

    private void btnBrand(ActionEvent e) {
        // TODO add your code here
        PanelBrandManager brandManager = new PanelBrandManager(this);
        panelMain.removeAll();
        panelMain.add(brandManager, BorderLayout.CENTER);
//        getContentPane().add(userManager,BorderLayout.CENTER);
        System.out.println("user");
        revalidate();
        repaint();
//        getContentPane().remove(userManager);
//        getContentPane().add(brandManager, BorderLayout.CENTER);
//        pack();
//        setSize(1100,800);
    }
    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - hui chen
        menuBar1 = new JMenuBar();
        menu1 = new JMenu();
        menuItem1 = new JMenuItem();
        menuItem3 = new JMenuItem();
        menuItem2 = new JMenuItem();
        toolBar1 = new JToolBar();
        btnUser = new JButton();
        btnBrand = new JButton();
        btnGoods = new JButton();
        panelMain = new JPanel();

        //======== this ========
        setTitle("\u5546\u5e97\u7ba1\u7406\u7cfb\u7edf");
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== menuBar1 ========
        {

            //======== menu1 ========
            {
                menu1.setText("\u7cfb\u7edf");

                //---- menuItem1 ----
                menuItem1.setText("\u7528\u6237\u6ce8\u518c");
                menu1.add(menuItem1);

                //---- menuItem3 ----
                menuItem3.setText("\u7528\u6237\u7ba1\u7406");
                menu1.add(menuItem3);
                menu1.addSeparator();

                //---- menuItem2 ----
                menuItem2.setText("\u9000\u51fa");
                menu1.add(menuItem2);
            }
            menuBar1.add(menu1);
        }
        setJMenuBar(menuBar1);

        //======== toolBar1 ========
        {
            toolBar1.setFloatable(false);

            //---- btnUser ----
            btnUser.setIcon(new ImageIcon(getClass().getResource("/img/\u7528\u6237.png")));
            btnUser.setToolTipText("\u7528\u6237\u7ba1\u7406");
            btnUser.addActionListener(e -> btnUser(e));
            toolBar1.add(btnUser);

            //---- btnBrand ----
            btnBrand.setIcon(new ImageIcon(getClass().getResource("/img/\u5546\u6807.png")));
            btnBrand.setToolTipText("\u54c1\u724c\u7ba1\u7406");
            btnBrand.addActionListener(e -> btnBrand(e));
            toolBar1.add(btnBrand);

            //---- btnGoods ----
            btnGoods.setIcon(new ImageIcon(getClass().getResource("/img/\u5546\u54c1.png")));
            btnGoods.setToolTipText("\u5546\u54c1\u7ba1\u7406");
            toolBar1.add(btnGoods);
        }
        contentPane.add(toolBar1, BorderLayout.NORTH);

        //======== panelMain ========
        {
            panelMain.setBorder (new javax. swing. border. CompoundBorder( new javax .swing .border .TitledBorder (new javax. swing. border. EmptyBorder
            ( 0, 0, 0, 0) , "JF\u006frmDes\u0069gner \u0045valua\u0074ion", javax. swing. border. TitledBorder. CENTER, javax. swing. border
            . TitledBorder. BOTTOM, new java .awt .Font ("D\u0069alog" ,java .awt .Font .BOLD ,12 ), java. awt
            . Color. red) ,panelMain. getBorder( )) ); panelMain. addPropertyChangeListener (new java. beans. PropertyChangeListener( ){ @Override public void
            propertyChange (java .beans .PropertyChangeEvent e) {if ("\u0062order" .equals (e .getPropertyName () )) throw new RuntimeException( )
            ; }} );
            panelMain.setLayout(new BorderLayout());
        }
        contentPane.add(panelMain, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - hui chen
    private JMenuBar menuBar1;
    private JMenu menu1;
    private JMenuItem menuItem1;
    private JMenuItem menuItem3;
    private JMenuItem menuItem2;
    private JToolBar toolBar1;
    private JButton btnUser;
    private JButton btnBrand;
    private JButton btnGoods;
    private JPanel panelMain;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
